namespace NGridDrawer.Partitions
{
    /// <LastUpdate author="Blaise Braye" Date="15/06/2008 17:02"/>
    /// <summary>
    /// Represents a level in a <see cref="PartitionGrid"/> object
    /// </summary>
    public class PartitionLevel : PartitionGridElement
    {
        private readonly int _firstRow;
        private readonly float _height;
        private readonly int _lastRow;


        /// <summary>
        /// 	<para>Initializes an instance of the <see cref="PartitionLevel"/> class.</para>
        /// </summary>
        /// <param name="grid"><see cref="PartitionGrid"/> object associated with this element</param>
        /// <param name="ordinal">Ordinal number of this partitionLevel</param>
        /// <param name="firstRow">First row of the source data grid which belongs to this partitionLevel</param>
        /// <param name="lastRow">Last row of the source data grid which belongs to this partitionLevel</param>
        /// <param name="height">Height of the partitionLevel</param>
        public PartitionLevel(PartitionGrid grid, int ordinal, int firstRow, int lastRow, float height)
            : base(grid)
        {
            Ordinal = ordinal;
            _firstRow = firstRow;
            _lastRow = lastRow;
            _height = height;
        }


        /// <summary>
        /// Get the first row of the source data grid which belongs to this partitionLevel
        /// </summary>
        public int FirstRow
        {
            get { return _firstRow; }
        }


        /// <summary>
        /// Get the last row of the source data grid which belongs to this partitionLevel
        /// </summary>
        public int LastRow
        {
            get { return _lastRow; }
        }


        /// <summary>
        /// Get the height of the partitionLevel
        /// </summary>
        public float Height
        {
            get { return _height; }
        }


        /// <summary>
        /// Gets the total number of the data grid rows belonging to the partitionLevel
        /// </summary>
        public int RowsCount
        {
            get { return 1 + LastRow - FirstRow; }
        }

        /// <summary>Get/Set Ordinal Property</summary>
        public int Ordinal { get; private set; }
    }
}